Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Simplify TransactionState #5078

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

apfitzge
Copy link

Problem

  • TransactionState used to contain raw packet information but it makes more sense for the state to be flat w/ a simple internal option now.

Summary of Changes

  • TransactionState contains all items directly instead of a separate SanitizedTransactionTTL

Fixes #

@apfitzge apfitzge force-pushed the simplify_transaction_state branch from 3612225 to b6afccc Compare February 27, 2025 20:24
@apfitzge apfitzge marked this pull request as ready for review February 27, 2025 21:26
@apfitzge apfitzge requested a review from tao-stones February 27, 2025 21:26
/// The transaction is currently scheduled or being processed.
Pending { priority: u64, cost: u64 },
/// Only used during transition.
Transitioning,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to see Transitioning is gone - always think transitioning between states itself is not a state.

/// Priority of the transaction.
priority: u64,
/// Estimated cost of the transaction.
cost: u64,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like max_age, priority and cost are properties associated with transaction that's ready for processing. If so, they can be bundled together to better describe "state", could also make container.insert_new_transaction( tx_with_its_properties ) cleaner. wdyt something like this instead of option<Tx>?

enum TransactionState<Tx> {
    Unprocessed {
        transaction: Tx,
        max_age: MaxAge,
        priority: u64,
        cost: u64,
        // or define a struct for above 4 fields
    },
    Processing,
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think it's fine to make a bundle of these, but only few actually need to be sent with the other items for processing (only max_age currently).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants